﻿using System;

namespace _61_重写ToString方法_类型转换
{
    class Program
    {
        static void Main(string[] args)
        {


            Production[] prs =
            {
                new Production
                {
                    ID=1,
                    Width=150,
                    Height=70,
                    SerialNum="T-31256- K3"
                },
                new Production
                {
                    ID=2,
                    Width=200,
                    Height=87,
                    SerialNum="T-3b3158 - K7"
                },
                new Production
                {
                    ID=3,
                    Width=300,
                    Height=87,
                    SerialNum="T-331a58 - K7"
                },
                new Production
                {
                    ID=4,
                    Width=400,
                    Height=837,
                    SerialNum="T-331258 - K7"
                },
                new Production
                {
                    ID=5,
                    Width=200,
                    Height=87,
                    SerialNum="T-331D58 - K7"
                }
            };

            foreach (Production item in prs)
            {
                Console.WriteLine(item);
            }
        }
    }
    public class Production
    {
        public int ID { get; set; }
        public int Width { get; set; }
        public int Height { get; set; }
        public string SerialNum { get; set; }

        //重写Tostring方法，返回自定义字符串，字符串可以由该类的属性构成
        public override string ToString()
        {
            return $"产品序列号：{SerialNum},规格(厘米):{Width} x {Height}";
        }
    }
}
